'''
Author: your name
Date: 2020-11-06 15:39:00
LastEditTime: 2020-11-06 15:51:05
LastEditors: Please set LastEditors
Description: In User Settings Edit
FilePath: \python-study\djangoS\app01\app01\Views\Book\orderExamples.py
'''
from django.shortcuts import render,HttpResponse
from Models.models import Book
from django.core import serializers

class orderExample():
    def order_example(request):
        books = Book.objects.order_by("price") # 查询所有，按照价格升序排列
        print(serializers.serialize('json',books))
        books = Book.objects.order_by("-price") # 查询所有，按照价格降序排列
        print(serializers.serialize('json',books))
        return HttpResponse("<p>查找成功！</p>")